package org.gd.rest.jersey.server;

import com.google.inject.Inject;

import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;

@Path("/hello")
public class Resource {

    @Inject
    private Counter counter;

    @GET
    @Produces(MediaType.TEXT_PLAIN)
    public String get() {
        return "Hello, User number TEXT_PLAIN " + counter.getNext();
    }

    @GET
    @Produces({
            MediaType.TEXT_XML,
            MediaType.APPLICATION_XML
    })
    public String getXml() {
        return "<rest>Hello, User number TEXT_PLAIN " + counter.getNext() + "</rest>";
    }

    @GET
    @Produces({MediaType.APPLICATION_JSON})
    public String getJson() {
        return "{ key: \"Hello, User number TEXT_PLAIN " + counter.getNext() + " \" }";
    }

    @POST
    public String post() {
        return "Hello, User number " + counter.getNext();
    }

    @PUT
    public String put() {
        return "Hello, User number " + counter.getNext();
    }
}
